#include "csppedplaylistdlg.h"
#include <QListWidget>
#include <QVBoxLayout>

CSpeedPlayListDlg::CSpeedPlayListDlg(QWidget *parent) : QDialog(parent)
{
    this->setFixedSize(80,230);
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip);
    //this->setStyleSheet("QDialog{background-color:red;}");
    this->setStyleSheet("QDialog{background-color:rgba(54,54,54,0.5);}");
    m_speedPlayList = new QListWidget(this);
    //m_speedPlayList->setFixedSize(80,230);
    //m_speedPlayList->setViewMode(QListView::ListMode);
    m_speedPlayList->setStyleSheet("QListWidget {background-color:#363738;}"
                                   "QListWidget::item:selected { background-color: #464748;padding-left:0px;padding-right:0px; }"
                                   "QListWidget::item {padding-left:0px;padding-right:0px;}");
    //m_speedPlayList->setStyleSheet("QListWidget{ background-color:green;border: none;background:transparent;margin-left: 0px;padding-left:0px; }"
    //                               "QListWidget::item:selected { color:green }");
    //m_speedPlayList->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
    //m_speedPlayList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    //m_speedPlayList->setStyleSheet("QScrollBar:vertical { width: 0px; height: 0px; }, QScrollBar:horizontal { width: 0px; height: 0px; }");
    m_speedPlayList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_speedPlayList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_speedPlayList->addItem("2.0X");
    m_speedPlayList->addItem("1.75X");
    m_speedPlayList->addItem("1.5X");
    m_speedPlayList->addItem("1.25X");
    m_speedPlayList->addItem("1.0X");
    m_speedPlayList->addItem("0.75X");
    m_speedPlayList->addItem("0.5X");
    m_speedVec.push_back(2.0);
    m_speedVec.push_back(1.75);
    m_speedVec.push_back(1.5);
    m_speedVec.push_back(1.25);
    m_speedVec.push_back(1.0);
    m_speedVec.push_back(0.75);
    m_speedVec.push_back(0.5);

    QVBoxLayout* pVlay = new QVBoxLayout(this);
    pVlay->setContentsMargins(0,0,0,0);
    //pVlay->setMargin(0);
    pVlay->addWidget(m_speedPlayList);
    connect(m_speedPlayList,&QListWidget::itemClicked,this,&CSpeedPlayListDlg::onListItemClicked);
}


void CSpeedPlayListDlg::onListItemClicked(QListWidgetItem *item){
    int index = m_speedPlayList->currentRow();
    emit speedPlaySignal(m_speedVec[index]);
}
